package com.cy;

import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.logging.Logger;

@SpringBootApplication
public class ProviderRun {
    public static void main(String[] args) {
        SpringApplication.run(ProviderRun.class, args);
    }
    @Value("${server.port}") //注入配置文件的值
    private  String server;

   // private static   final Logger log=LoggerFactory.getLogger(ProviderRun.class);

    @RestController
    @RefreshScope//动态刷新配置文件的内容
    public class  ProviderController{
        //获取我们设置的启动类的错误级别


        @Value("${logging.level.com.cy:error}")
        private String logLevel;

        //处理配置文件的方法
        @GetMapping("/prd/config")
     public String doGetConfigure(){



        return "我们配置的错误界别是"+logLevel;

     }




      //普通方式的调用，没有负载均衡
        @GetMapping("/provider/echo/{msg}")
        public String doEcho( @PathVariable String msg){

            //return server+"说：学个棉线的巴拉"+msg;


            return "这是："+server+"学个棉线的巴拉"+msg;

        }


        //feign 的方式调用的数据请求方法
        @GetMapping("/prd/echo3/{msg}")
        public String doFeign( @PathVariable String msg) throws InterruptedException {
          //Thread.sleep(5222222);
            return server+"说：学个棉线的巴拉"+msg;
        }
    }

}
